package co.legu.carpool.util;

import java.awt.*;
import java.awt.image.BufferedImage;

/**
 * 二维码公用类
 */
public class QrCodeUtils {


    public static void writeBgImgAndText(BufferedImage bg,BufferedImage qrCodeImage,String text,
                                      int imgX,int imgY,int imgWidth,int imgHeight,
                                      int textY,int textFontSize,Color color){
        Graphics2D gs = bg.createGraphics();
        gs.drawImage(qrCodeImage,imgX,imgY,imgWidth,imgHeight,null);
        //写入文字
        gs.setColor(color);
//        gs.fillRect(0, 0, 200, 50);
        gs.setFont(new Font("fonts-wqy-microhei", Font.BOLD, textFontSize));
        var width = bg.getWidth();
        var x = (width - (text.length() * textFontSize)) / 2;
        gs.drawString(text, x, textY);
        gs.dispose();
    }
}
